1. Field of the Invention
The present invention is directed to technology for adding functionality to existing code at exits.
2. Description of the Related Art
Performance profiling (or analysis) tools are popular tools used to debug software and to analyze an application's run time execution. Many performance profiling tools provide timing data on how long each method (or procedure or other process) is being executed, report how many times each method is executed and/or identify the function call architecture. Other functions can also be performed by various performance profiling tools. Some of the tools provide their results in text files or on a monitor. Other tools graphically display their results.
Many performance analysis tools perform their intended function by either instrumenting source code or instrumenting object code. Object code can be generated by a compiler or an assembler. Alternatively, object code can be generated manually. Object code can be machine executable or suitable for processing to produce executable machine code.
Instrumenting source code involves adding new instructions to source code and/or modifying existing instructions in the source code. Instrumenting object code includes adding new instructions to the object code and/or modifying existing instructions in the object code. Instrumenting object code does not involve accessing the source code. An example of instrumenting object code can be found in U.S. patent application Ser. No. 09/137,666, filed on Aug. 20, 1998, by Lewis K. Cirne, incorporated herein by reference.
One problem with instrumenting source code to provide performance profiling is that the source code may not be available. Thus, many performance profiling tools will add the performance profiling functionality by instrumenting the object code.
One difficulty in instrumenting code is that a method (or other set of instructions) may include many exits. Consider the following code for a method called “isNegative” which returns a Boolean value indicating whether a parameter is negative:                Boolean isNegative (int x)                    {            if (x<0)                            return true;                else return false;                                    }The above method includes at least two exit points. If the parameter x is less than 0, then the method exists at the “return true” instruction. If the parameter x is not less than 0, then the method exists at the “return false” instruction. Prior art systems that add performance profiling functionality will add new code to each of the exits in the code. For example, code will be added to the return clause and the else clause of the code above.                        
Adding performance profiling code to each of the instructions that each can be an exit has its drawbacks. First, the same code may be added in several places which can significantly increase the amount of code in an application. A significant increase in code may impact the performance of the application and increase the chance of adding an error to the application. Additionally, the greater the number of exits, the greater chance that the system adding performance profiling code will miss one of the exits. Finally, not all of the exits are explicitly stated in the code. For example, there can be errors or exceptions. When an error or an exception occurs, the normal flow of the method can be halted, in which case none of the explicit exits will be performed and an exit associated with the error or exception will be performed. Previous performance profiling tools have not adequately accounted for all the possible exits in the software.
Therefore, what is needed is a system for adding performance profiling functionality to object code such that the new functionality is provided for all (or almost all) exits of the method (or other set of code). This need extends beyond just performance profiling tools. Thus, there is a need to add functionality to existing object code at the exits for a particular method (or other set of code) under consideration.